package twentytwenty;

/**
 * @Author: Spider Man
 * @Description:
 * @Date Created in 2020-09-22 9:53
 * @Modified By:
 */
public class RemoveDuplicates_26 {
    public static void main(String[] args) {
        int [] nums = new int[]{1,1,2};
        System.out.println(removeDuplicates(nums));
    }

    public static int removeDuplicates(int[] nums) {
        if (nums.length == 0) return 0;
        int result = 0;
        for (int j = 1; j < nums.length; j++) {
            if (nums[j] != nums[result]) {
                result++;
                nums[result] = nums[j];
            }
        }
        return result + 1;
    }
}
